<include file="__THEME__/public_header" />
<div class="content">
	<div class="wrap">
    	<div class="con_side">
        	<ul class="nav">
            	<li><a href="{:U('admin/Privilege/index')}">市级账号</a></li>
                <li><a href="{:U('admin/Privilege/show_area_user')}">区级账号</a></li>
                <li class="cursor"><a href="{:U('admin/Privilege/show_garden_user')}">园级账号</a></li>
            </ul>
        </div>
        <div class="con_main">
        	<div class="con_tit">
            	<ul class="con_link">
                    <li><a href="{:U('admin/Privilege/show_garden_user')}">筛选</a></li>
                    <li class="on"><a href="javascript:;">新建用户</a></li>
                </ul>
            </div>
            <div class="con_box">
            	<ul class="slect_list2">
                    <li>
                        <div class="txt">选择省级：</div>
                        <div class="inp">
                            <select id="Province" onchange="selectArea(1);">
                                <option value="">----请选择----</option>
                                <volist name="province" id="province">
                                    <option value="{$province.area_id}">{$province.title}</option>
                                </volist>
                            </select>
                        </div>
                    </li>
                </ul>
                <ul class="slect_list2">
                     <li>
                        <div class="txt">选择市级：</div>
                        <div class="inp">
                            <select id="City" onchange="selectArea(2);">
                                <option value="0">----请选择----</option>
                            </select>
                        </div>
                    </li>
                </ul>
                <ul class="slect_list2">
                     <li>
                        <div class="txt">选择区级：</div>
                        <div class="inp">
                            <select id="Area">
                                <option value="0">----请选择----</option>
                            </select>
                        </div>
                    </li>
                </ul>
                <ul class="slect_list2">
                     <li>
                        <div class="txt">幼儿园类型：</div>
                        <div class="inp">
                            <select name="type" id="type">
                                <option value="0">----请选择----</option>
                                <option value="1">市级示范</option>
                                <option value="2">区级示范</option>
                                <option value="3">一级一类</option>
                                <option value="4">一级二类</option>
                                <option value="5">二级一类</option>
                                <option value="6">二级二类</option>
                                <option value="7">其他</option>
                            </select>
                        </div>
                    </li>
                </ul>
                <ul class="slect_list2">
                     <li>
                        <div class="txt">幼儿园名：</div>
                        <div class="inp">
                            <input type="text" id="uname" style="height:30px;">
                        </div>
                    </li>
                </ul>
                <ul class="slect_list2">
                     <li>
                        <div class="txt">所处位置：</div>
                        <div class="inp">
                            <input type="radio" name="location" value="1" checked="checked">市内
                            <input type="radio" name="location" value="2">郊区
                        </div>
                    </li>
                </ul>
                <ul class="slect_list2">
                     <li>
                        <div class="txt">密码：</div>
                        <div class="inp">
                            <input type="text" id="pwd" style="height:30px;">
                        </div>
                    </li>
                </ul>
            	<div class="action_link tc small">
                    <a class="save" href="javascript:doAddUser();">确定</a>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function selectArea(type){
        if(type==1){
            var pid=$("#Province").val();
            var name="City";
        }else{
            var pid=$("#City").val();
            var name="Area";
        }
        if(pid>0){
            $.ajax({
              type: "GET",
              url:"{:U('public/TestData/getArea')}",
              data:"pid="+pid,
              dataType:"json",
              success:function(data){
                $("#"+name).html("");
                $("#"+name).append("<option value='0'>----请选择----</option>");
                $.each(data,function(i,item){
                  $("#"+name).append("<option value='"+item.area_id+"'>"+item.title+"</option>");
                }); 
              }
            });
        }
    }
    function doAddUser(){
        var Province=$("#Province").val();
        var City=$("#City").val();
        var Area=$("#Area").val();
        var uname=$("#uname").val();
        var location=$("#City   option:selected").text()+$("#Area   option:selected").text();
        var pwd=$("#pwd").val();
        var type=$("#type").val();
        var schoollocation=$('input[name="location"]:checked ').val();
        if(Area==0){
            alert("请选择地区");
            return;
        }
        if(type==0){
            alert("请选择幼儿园类型");
            return;
        }
        if(uname==""){
            alert("请输入幼儿园名");
            return;
        }
        if(pwd==""){
            alert("请输入密码");
            return;
        }
        $.ajax({
            type: "POST",
            url:"{:U('admin/Privilege/addUser')}",
            data:"usertype=4&Province="+Province+"&City="+City+"&uname="+uname+"&Area="+Area+"&pwd="+pwd+"&location="+location+"&schoollocation="+schoollocation+"&type="+type,
            dataType:"text",
            success:function(data){
                if(isNaN(data)){
                    alert(data);
                }else{
                    window.location.href="{:U('admin/Privilege/show_garden_user')}";
                }
            }
        });
    }
</script>
<include file="__THEME__/public_footer" />